<button class="btn btn-success btn-xs" data-toggle="modal" data-target="#taskTransfer{{ $id }}">调配资源</button>

<div class="modal fade" id="taskTransfer{{ $id }}" tabindex="-1" role="dialog" aria-labelledby="taskTransfer"
     aria-hidden="true">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">调配资源-{{ $name }}(<span
                        style="color:red; font-size:12px">公司之间资源分配</span>)</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">公司名</label>
                    <select type="text" name="transferUserId{{ $id }}" class="form-control">
                        @if(!empty($data))
                            @foreach($data as $key => $value)
                                <option value="{{ $key }}">{{ $value }}</option>
                            @endforeach
                        @endif
                    </select>
                </div>
                @if(!empty($record))
                    <div class="mb-3">
                        <table class="table table-hover grid-table">
                            <thead style="text-align:center">
                            <tr>
                                <th>资源调配记录(<span style="color:red; font-size:12px">调配次数：{{ count($record) }}次</span>)</th>
                            </tr>
                            <tr>
                                <th>目标公司</th>
                                <th>时间</th>
                            </tr>
                            </thead>
                            <tbody>

                            @foreach($record as $value)
                                <tr>
                                    <td>{{ $value['company_name'] }}</td>
                                    <td>{{ date('Y-m-d H:i:s', strtotime($value['created_at'])) }}</td>
                                </tr>
                            @endforeach

                            </tbody>
                        </table>
                    </div>
                @endif
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="taskTransfer({{ $id }})">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function taskTransfer(id) {
        ajaxPostFunc('/admin/ajax/taskTransfer', {
            id: id,
            follow_user_id: $("select[name='transferUserId" + id + "'] option:selected").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
